package com.globallogic.model;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import org.apache.log4j.Logger;

public class Md5Encoder {

    public static String getEncodedValue(String value) {

        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] passwordBytes = value.getBytes("UTF-8");
            byte[] digest = md.digest(passwordBytes);
            
            return new String(digest);

        } catch (NoSuchAlgorithmException e) {
            logger.error(e);
        } catch (UnsupportedEncodingException e) {
            logger.error(e);
        }
        return "";
    }
    
    private static Logger logger = Logger.getLogger(Md5Encoder.class);
    
}
